package com.personal.dao;

import com.personal.domain.OccupancyApply;
import com.personal.util.partDisplay.OccupancyApplyPart;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OccupancyApplyDao {



    @Select("select * from resourcesettlementapplication;")
    List<OccupancyApply> selectAll();


    @Select("select id,serviceProviderName,headOfEnterprise,headOfEnterprisePhone,headOfEnterprisePhone,enterpriseAddress,serviceType,documentStatus from resourcesettlementapplication")
    List<OccupancyApplyPart> selectPartAll();

    @Select("select id,serviceProviderName,headOfEnterprise,headOfEnterprisePhone,headOfEnterprisePhone,enterpriseAddress,serviceType,documentStatus from resourcesettlementapplication" +
            " where serviceProviderName like CONCAT('%',#{name},'%') and serviceType like CONCAT('%',#{type},'%')")
    List<OccupancyApplyPart> selectPartByKey(String name, String type);

    @Insert(" insert into resourcesettlementapplication (id,serviceProviderName, headOfEnterprise, headOfEnterprisePhone, enterpriseAddress," +
            "                                                   serviceType, applicationDate, documentStatus, companyProfile, companyDetails, logo," +
            "                                                   bannerPicture, businessLicense, IdCardPositive, idCardReverse)" +
            "                    values (null,#{serviceProviderName}, #{headOfEnterprise}, #{headOfEnterprisePhone}, #{enterpriseAddress}," +
            "                            #{serviceType}, #{applicationDate}, #{documentStatus}, #{companyProfile}, #{companyDetails}, #{logo}," +
            "                            #{bannerPicture}, #{businessLicense}, #{IdCardPositive}, #{idCardReverse})")
    int add(OccupancyApply occupancyApply);

    @Select("select * from resourcesettlementapplication where id=#{id}")
    OccupancyApply getUpdateData(int id);
    @Update("update resourcesettlementapplication set serviceProviderName=#{serviceProviderName},headOfEnterprise=#{headOfEnterprise},headOfEnterprisePhone=#{headOfEnterprisePhone}," +
            "                                                 enterpriseAddress=#{enterpriseAddress},serviceType=#{serviceType},applicationDate=#{applicationDate}," +
            "                                                 documentStatus=#{documentStatus},companyProfile=#{companyProfile},companyDetails=#{companyDetails}," +
            "                                                 logo=#{logo},bannerPicture=#{bannerPicture},businessLicense=#{businessLicense},IdCardPositive=#{IdCardPositive}," +
            "                                                 idCardReverse=#{idCardReverse} where id=#{id}")
    int update(OccupancyApply occupancyApply);

    @Delete("delete from resourcesettlementapplication where id=#{id}")
    int delete(int id);
}
